import {Result} from '@/base/Result';
import {request} from '@/base/Request';
import {Page} from '@/base/Page';
import {Benefits} from '@/base/model/Benefits';
import qs from 'qs';

export function  getBenefitsList(params: {
  pageIndex: number;
  pageSize: number;
  sortDirection: string;
}): Promise<Result<Page<Benefits>>> {

  return request.getPage(Benefits, '/api/member-level/fetchBenefit', {params});
}

export function deleteBenefits(benefitId: number): Promise<Result<void>> {
  return request.delete(`/api/member-level/fetchBenefit/${benefitId}`);
}

export function addBenefits(params: {
  benefitname: string;
  description: string;
  benefitIcon: string;
}){
  return request.post(Benefits, '/api/member-level/addBenefit',qs.stringify(params));
}

export function getBenefits(benefitId: number): Promise<Result<Benefits>> {
  return request.get(Benefits, `/api/member-level/${benefitId}`);
}

export function  editBenefits(params: {
  benefitIcon: string;
  benefitId: number;
  benefitname: string;
  description: string;

}){
  return request.put(Benefits, '/api/member-level/updateBenefit', qs.stringify(params));
}
